﻿namespace PathFind.Algo {
    public class Node {
        public Coordinate pos;
        public float Total { get; private set; }
        public float Score { get; private set; }
        public Node parent;
        public Direction dir;

        public Node() {
        }

        public Node(float total) {
            Total = total;
        }

        public void Reset(Coordinate p, Node pnt, Coordinate goalPos, Direction direction) {
            pos = p;
            parent = pnt;
            dir = direction;
            if (parent != null) {
                Score = pos.CallDistFunc(pnt.pos) + pnt.Score;
            }
            else {
                Score = 0;
            }

            Total = Score + p.CallDistFunc(goalPos);
        }

        public override string ToString() {
            return $"({pos.x}, {pos.y}) Score:{Score} {Total:F1} ";
        }
    }
}